<template>
  <div>
<h1>修改页面{{bid}}</h1>
<p>书名：<input type="text" v-model="name"></p>
<p>分类：<input type="text" v-model="cate"></p>
<p>简介：<input type="text" v-model="intro"></p>
<p>价格：<input type="text" v-model="price"></p>
<p><input type="file" id="img"></p>
<p><input type="button" value="修改" @click="upbooks"></p>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
          bid:this.$route.query.bid,
          name:'',
          cate:'',
          intro:'',
          price:'',
        }
    },
    methods:{
      upbooks() {
          file=document.getElementById('img').files[0]
        let fdata=new FormData()
        fdata.append('name',this.name)
        fdata.append('cate',this.cate)
        fdata.append('intro',this.intro)
        fdata.append('price',this.price)
        fdata.append('img',file)
        axios({
          url:'http://127.0.0.1:8000/app01/upbooks/'+this.bid,
          method:'put',
          data:fdata
        }).then(resp=>{
          console.log(resp.data)
        })
      }
    }
}
</script>

<style>

</style>